<?php


// no direct access
defined('_JEXEC') or die('Restricted access');


$siteURL = JURI::base();
$document = JFactory::getDocument();
$document->addScript($siteURL . 'modules/mod_chatter/chatter.js');
$document->addStyleSheet($siteURL . 'modules/mod_chatter/styles.php');

$session = JFactory::getSession();
$user = JFactory::getUser();
$nick = $session->get('chatter.nick');	// It should already be escaped.


?>

<script type="text/javascript"><!-- <![CDATA[
JCCU.Chatter.lastLinePosted = '<?php echo $chatter->lastLinePosted ?>';
JCCU.Chatter.setMinimumInterval(5);
//]]> --></script>
<div id="mod_chatter">
	<div class="wrapper">
		<div id="mod_chatter_lines">
<?php foreach ($chatter->lines as $line) { ?>
			<div class="line"><span class="nick <?php echo $line->color ?>"><?php echo $line->nick ?></span>:
			<span class="message"><?php echo modChatterHelper::formatMessage($line->message) ?></span></div>
<?php } ?>
		</div>

		<form action="modules/mod_chatter/actions.php" method="POST" onsubmit="return false">
			<table alt="">
				<tbody>
					<tr>
						<th width="60">Name:</th>
						<td>
<?php if (!$user->guest) { ?>
							<strong><?php echo JFilterOutput::cleanText($user->username) ?></strong>
							<input maxlenth="45" name="nick" type="hidden" value="<?php echo JFilterOutput::cleanText($user->username) ?>"/>
<?php } else { ?>
							<input maxlenth="45" name="nick" type="text" style="width:90%" value="<?php echo $nick ?>"/>
<?php } ?>
						</td>
					</tr>
					<tr>
						<td colspan="2"><textarea name="message" style="width:100%" onkeypress="return JCCU.Chatter.onKeyPress(this,event)"/></textarea></td>
					</tr>
				</tbody>
				<tfoot>
					<tr>
						<td align="right" colspan="2"><input type="submit" value="Send" onclick="JCCU.Chatter.submit(this.form)"/></td>
					</tr>
				</tfoot>
			</table>
			<input name="task" type="hidden" value="post"/>
		</form>


	</div>
</div>
